/****************************************************************************************
 *
 * File Name: kf_it.c
 * Project Name: KF32A156_USART
 * Version: v1.0
 * Date: 2021-07-13- 19:14:54
 * Author: zqz
 * 
 ****************************************************************************************/
#include"system_init.h"
#include "Usart.h"
extern Usart_Sdu_Type  Usart_Receive_Sdu;
//*****************************************************************************************
//                                 NMI Interrupt Course
//*****************************************************************************************	
void __attribute__((interrupt)) _NMI_exception (void)
{	

}

//*****************************************************************************************
//                               HardFault Interrupt Course
//*****************************************************************************************	

void __attribute__((interrupt)) _HardFault_exception (void)
{

}

//*****************************************************************************************
//                               StackFault Interrupt Course
//*****************************************************************************************	
void __attribute__((interrupt)) _StackFault_exception (void)
{

}

//*****************************************************************************************
//                               SVC Interrupt Course
//*****************************************************************************************	
void __attribute__((interrupt)) _SVC_exception (void)
{

}

//*****************************************************************************************
//                              SoftSV Interrupt Course
//*****************************************************************************************	
void __attribute__((interrupt)) _SoftSV_exception (void)
{

}

//*****************************************************************************************
//                              SysTick Interrupt Course
//*****************************************************************************************	
void __attribute__((interrupt)) _SysTick_exception (void)
{
	
}

//*****************************************************************************************
//                               USART1 Interrupt Course
//*****************************************************************************************
/* Usart1 receive data count */
uint16_t UsartRxBuffer[10];
void __attribute__((interrupt)) _USART1_exception (void)
{
	static uint32_t ReceiveCount = 0;
	/*	If gets the status of the USART data ready interrupt flag */
	if(USART_Get_Receive_BUFR_Ready_Flag(USART1_SFR))
	{
		UsartRxBuffer[ReceiveCount++] = USART_ReceiveData(USART1_SFR);

	}
	/* If USART1 gets 10 pieces of data */
	if (ReceiveCount >= 10)
	{
		for(uint8_t i = 0; i < 10; i++)
		{
			printf("%c",UsartRxBuffer[i]);
		}
		memset(UsartRxBuffer, 0, sizeof(UsartRxBuffer));
		/* Gets the length of the data received */
		ReceiveCount = 0;
	}
}


